int calculate(char* s) {

	int x = 1;
	int y = 0;
	while (*s) {
		if (*s == 'A')
			x = 2 * x + y;
		else if (*s == 'B')
			y = 2 * y + x;
		s++;
	}
	return x + y;
}